<?php

namespace App\Console\Commands;

use App\Models\FloorRoom;
use Carbon\Carbon;
use Illuminate\Console\Command;

class CreateRoomData extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:create_room_data';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '创建房间号数据';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        return true; // 关闭数据导入
        for ($i= 1; $i<=6; $i++){
            if($i == 1){
                for($j=101; $j<=120; $j++){
                    $data = [];
                    $orders = FloorRoom::orderBy('order', 'desc')->first();
                    $order = $orders->order + 1;
                    $data['name'] = '第 13 栋';
                    $data['building_no'] = '13';
                    $data['floor_no'] = $i;
                    $data['room_no'] = $j;
                    $data['order'] = $order;
                    $data['status'] = 1;
                    $data['created_at'] = Carbon::now();
                    $data['updated_at'] = Carbon::now();
                    FloorRoom::insert($data);
                }
            }
            if($i == 2){
                for($j=201; $j<=248; $j++){
                    $data = [];
                    $orders = FloorRoom::orderBy('order', 'desc')->first();
                    $order = $orders->order + 1;
                    $data['name'] = '第 13 栋';
                    $data['building_no'] = '13';
                    $data['floor_no'] = $i;
                    $data['room_no'] = $j;
                    $data['order'] = $order;
                    $data['status'] = 1;
                    $data['created_at'] = Carbon::now();
                    $data['updated_at'] = Carbon::now();
                    FloorRoom::insert($data);
                }
            }
            if($i == 3){
                for($j=301; $j<=348; $j++){
                    $data = [];
                    $data['name'] = '第 13 栋';
                    $data['building_no'] = '13';
                    $data['floor_no'] = $i;
                    $data['room_no'] = $j;
                    $orders = FloorRoom::orderBy('order', 'desc')->first();
                    $order = $orders->order + 1;
                    $data['order'] = $order;
                    $data['status'] = 1;
                    $data['created_at'] = Carbon::now();
                    $data['updated_at'] = Carbon::now();
                    FloorRoom::insert($data);
                }
            }
            if($i == 4){
                for($j=401; $j<=448; $j++){
                    $data = [];
                    $data['name'] = '第 13 栋';
                    $data['building_no'] = '13';
                    $data['floor_no'] = $i;
                    $data['room_no'] = $j;
                    $orders = FloorRoom::orderBy('order', 'desc')->first();
                    $order = $orders->order + 1;
                    $data['order'] = $order;
                    $data['status'] = 1;
                    $data['created_at'] = Carbon::now();
                    $data['updated_at'] = Carbon::now();
                    FloorRoom::insert($data);
                }
            }
            if($i == 5){
                for($j=501; $j<=548; $j++){
                    $data = [];
                    $data['name'] = '第 13 栋';
                    $data['building_no'] = '13';
                    $data['floor_no'] = $i;
                    $data['room_no'] = $j;
                    $orders = FloorRoom::orderBy('order', 'desc')->first();
                    $order = $orders->order + 1;
                    $data['order'] = $order;
                    $data['status'] = 1;
                    $data['created_at'] = Carbon::now();
                    $data['updated_at'] = Carbon::now();
                    FloorRoom::insert($data);
                }
            }
            if($i == 6){
                for($j=601; $j<=648; $j++){
                    $data = [];
                    $data['name'] = '第 13 栋';
                    $data['building_no'] = '13';
                    $data['floor_no'] = $i;
                    $data['room_no'] = $j;
                    $orders = FloorRoom::orderBy('order', 'desc')->first();
                    $order = $orders->order + 1;
                    $data['order'] = $order;
                    $data['status'] = 1;
                    $data['created_at'] = Carbon::now();
                    $data['updated_at'] = Carbon::now();
                    FloorRoom::insert($data);
                }
            }
        }

        //FloorRoom::insert()
    }
}
